<%--                                                                       --%>
<%-- Copyright (c) 2004 BroadVision, Inc.  All rights reserved.            --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %> 
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<% String ctxPath = request.getContextPath(); %>

<script language="javascript" src="<%= ctxPath %>/mt/js/date.js"></script>

<script language="javascript">

<%@ include file="/mc/common/jsutils.jsp" %>

  function doPageTypeNewAction(myform) {
    myform.pageTypeId.value = 0;
    myform.goBackAction.value = '/ep/pageTypeSearch.do';
    myform.action = '<c:url value="/ep/pageTypeNew.do"/>';
    myform.submit();
  }

  function doOnePageTypeEditAction(oid) {
    document.epPageTypeSearchForm.pageTypeId.value = oid;
    document.epPageTypeSearchForm.action = '<c:url value="/ep/pageTypeEdit.do"/>';
    document.epPageTypeSearchForm.submit();
  }

  function doOnePageTypeDeleteAction(oid) {
    if (confirm('<bean:message key="ep.page.type.confirm.delete" bundle="ep.messages"/>') != true) {
      return;
    }
    document.epPageTypeSearchForm.pageTypeId.value = oid;
    document.epPageTypeSearchForm.goBackAction.value = '/ep/pageTypeSearch.do';
    document.epPageTypeSearchForm.listSessionAttribute.value = 'PageTypeSearchResult';
    document.epPageTypeSearchForm.action = '<c:url value="/ep/pageTypeDelete.do"/>';
    document.epPageTypeSearchForm.submit();
  }

  function checkNumberOnly(e) {
    var charCode = (navigator.appName == "Netscape") ? e.which : e.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
      return false;
    }
    else {
      return true;
    }
  }

  function validateForm() {
    if (document.epPageTypeSearchForm.includeLastModifiedDateFrom.checked &&
      document.epPageTypeSearchForm.includeLastModifiedDateTo.checked) {
      var dateFrom = getDateOnly("epPageTypeSearchForm", "lastModifiedDateFrom");
      var dateTo = getDateOnly("epPageTypeSearchForm", "lastModifiedDateTo");
      if (dateTo < dateFrom) {
        alert('<bean:message key="error.search.dateRange" bundle="ep.messages"/>');
        return false;
      }
    }
    if (document.epPageTypeSearchForm.maxNumberToFind.value <= 0) {
      alert('<bean:message key="error.search.maxFound" bundle="ep.messages"/>');
      return false;
    }
    return true;
  }

</script>

<c:set var="editImg">
<img src="<%= ctxPath %>/ep/images/action/icon_edit.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean:message key="image.alt.edit" bundle="ep.messages"/>" title="<bean:message key="image.alt.edit" bundle="ep.messages"/>">
</c:set>
<c:set var="deleteImg">
<img src="<%= ctxPath %>/ep/images/action/icon_delete.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean:message key="image.alt.delete" bundle="ep.messages"/>" title="<bean:message key="image.alt.delete" bundle="ep.messages"/>">
</c:set>

<html:form action="/ep/pageTypeSearch.do" focus="pageTypeName" onsubmit="return validateForm();">
<input type="hidden" name="pageTypeId"/>
<input type="hidden" name="goBackAction"/>
<input type="hidden" name="listSessionAttribute"/>
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="pageTitle">
<c:choose>
  <c:when test="${list != null}">
        <bean:define id="count" name="pager" property="count" type="java.lang.Integer"/>
        <bean:message key="ep.page.types.searchFound.page.title" arg0='<%= count.toString() %>' bundle="ep.messages"/>
  </c:when>
  <c:otherwise>
        <bean:message key="ep.page.types.search.page.title" bundle="ep.messages"/>
  </c:otherwise>
</c:choose>
      </div>
      <div class="errorMessage"><html:errors bundle="ep.messages"/></div>
      <div class="pageSubtitle">
        <span class="left">
          <bean:message key="ep.search.criteria" bundle="ep.messages"/>
        </span>
        <span class="right">
          <input type="button" class="inputButton" value='<bean:message key="button.new.pagetype" bundle="ep.messages"/>'
            onclick="doPageTypeNewAction(this.form);">
        </span>
      </div>
      <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Search criteria">
        <tr> 
          <td class="label" width="20%">
            <bean:message key="ep.label.name" bundle="ep.messages"/>:
          </td>
          <td class="labelField" width="80%" colspan="2">
            <html:text property="pageTypeName" maxlength="80" size="31"/>
          </td>
        </tr>
        <tr> 
          <td class="label" width="20%">
            <bean:message key="ep.label.lastModifiedDate" bundle="ep.messages"/>:
          </td>
          <td class="labelField" width="10%" nowrap>
            <html:checkbox property="includeLastModifiedDateFrom"/>
            <bean:message key="ep.label.from" bundle="ep.messages"/>
          </td>
          <td class="labelField" width="70%" nowrap>
            <bvhtml:date name="epPageTypeSearchForm" property="lastModifiedDateFrom" 
              onChangeMonth="onChangeMonth" onChangeYear="onChangeYear" noblank="true"/>
            <a href="JavaScript:datePopup('<html:rewrite page="/mt/calendar.do"/>',
              'epPageTypeSearchForm', 'lastModifiedDateFrom')">
              <img src="<%= ctxPath %>/ep/images/action/calendar.gif"
                 width="22" height="22" alt='<bean:message key="image.alt.chooseDate"  bundle="ep.messages"/>'
                 title='<bean:message key="image.alt.chooseDate"  bundle="ep.messages"/>' border="0" align="absmiddle"/></a>
          </td>
        </tr>
        <tr>
          <td class="label" width="20%">&nbsp;</td>
          <td class="labelField" width="10%" nowrap>
            <html:checkbox property="includeLastModifiedDateTo"/>
            <bean:message key="ep.label.to" bundle="ep.messages"/>
          </td>
          <td class="labelField" width="70%" nowrap>
            <bvhtml:date name="epPageTypeSearchForm" property="lastModifiedDateTo"
              onChangeMonth="onChangeMonth" onChangeYear="onChangeYear" noblank="true"/>
            <a href="JavaScript:datePopup('<html:rewrite page="/mt/calendar.do"/>',
              'epPageTypeSearchForm','lastModifiedDateTo')">
              <img src="<%= ctxPath %>/ep/images/action/calendar.gif"
                 width="22" height="22" alt='<bean:message key="image.alt.chooseDate"  bundle="ep.messages"/>'
                 title='<bean:message key="image.alt.chooseDate"  bundle="ep.messages"/>' border="0" align="absmiddle"/></a>
          </td>
        </tr>
        <tr> 
          <td class="label" width="20%">
            <bean:message key="ep.label.sortBy" bundle="ep.messages"/>:
          </td>
          <td class="labelField" width="80%" colspan="2">
            <html:select property="sortBy" size="1">
              <html:option value="-1"><bean:message key="ep.label.select" bundle="ep.messages"/></html:option>
              <html:option value="0"><bean:message key="ep.label.name" bundle="ep.messages"/></html:option>
              <html:option value="1"><bean:message key="ep.label.lastModifiedDate" bundle="ep.messages"/></html:option>
            </html:select>
            &nbsp;&nbsp;
            <span class="label">
              <bean:message key="ep.label.maxRows" bundle="ep.messages"/>:
            </span>
            <html:select property="rowPerPage" size="1">
              <html:option value="10">10</html:option>
              <html:option value="20">20</html:option>
              <html:option value="30">30</html:option>
              <html:option value="50">50</html:option>
              <html:option value="100">100</html:option>
            </html:select>
          </td>
        </tr>
        <tr> 
          <td class="label" width="20%">
            <bean:message key="ep.label.maxFind" bundle="ep.messages"/>:
          </td>
          <td class="labelField" width="80%" colspan="2">
            <html:text property="maxNumberToFind" maxlength="3" size="3" onkeypress="return checkNumberOnly(event)"/>
          </td>
        </tr>
      </table>
      <div class="pageButtonWrap" align="right">
        <input hspace="40" type="submit" name="actionSearch" class="pageButton" value="<bean:message key="button.showResults" bundle="ep.messages"/>">
      </div>
      <br>
<c:if test="${list != null}">
      <div class="pageSubtitle">
        <span class="left">
          <bean:define id="count1" name="pager" property="count" type="java.lang.Integer"/>
          <bean:message key="ep.label.search.results" arg0='<%= count1.toString() %>' bundle="ep.messages"/>
        </span>
        <span class="right">&nbsp;</span>
      </div>
      <div class="pageInstructions">
      </div>
      <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
        <tr class="listHeader">
          <th id="Name" align="left">
            <bean:message key="ep.header.name.page.type" bundle="ep.messages"/>
          </th>
          <th id="Description" align="left">
            <bean:message key="ep.header.description" bundle="ep.messages"/>
          </th>
          <th id="LastModifiedDate" align="left">
            <bean:message key="ep.header.lastModifiedDate" bundle="ep.messages"/>
          </th>
          <th id="Actions" align="left" nowrap>
            <bean:message key="ep.header.actions" bundle="ep.messages"/>
          </th>
        </tr>
  <c:choose>
    <c:when test="${not empty list}">
      <c:forEach var="item" items="${list}" varStatus="status">
        <c:choose>
          <c:when test="${(status.count + 1) % 2 == 0}">
	      <tr class="listEven">
          </c:when> 
  	      <c:otherwise>
	      <tr class="listOdd">
  	      </c:otherwise>
        </c:choose>
        <c:url var="viewUrl" value="/ep/pageTypeView.do">
          <c:param name="pageTypeId" value="${item.map.id}"/>
        </c:url>
          <td headers="Name">
            <a href='<c:out value="${viewUrl}"/>'>
              <c:out value="${item.map.name}"/></a>
          </td>
          <td headers="Description">
            <c:out value="${item.map.description}"/>
          </td>
          <td headers="LastModifiedDate">
            <bean:write name="item" property="lastModifiedDate" formatKey="format.datetime.short" bundle="ep.messages"/>
          </td>
          <td headers="Actions">
            <a href='#' onclick="doOnePageTypeEditAction('<c:out value="${item.map.id}"/>');">
              <c:out value='${editImg}' escapeXml="false"/></a>
        <c:if test="${item.map.userTemplatesCount <= 0}">
            <a href='#' onclick="doOnePageTypeDeleteAction('<c:out value="${item.map.id}"/>');">
              <c:out value='${deleteImg}' escapeXml="false"/></a>
        </c:if>
          </td>
        </tr>
      </c:forEach>
    </c:when>
    <c:otherwise>
        <tr class="listOdd">
          <td align="center" colspan="4">
            <bean:message key="ep.page.types.searchNoFound" bundle="ep.messages"/>
          </td>
        </tr>
    </c:otherwise>
  </c:choose>
      </table>
  <c:if test="${not empty list}">
<%@ include file="/mc/common/pager.jsp" %>
  </c:if>
</c:if>
    </td>
  </tr>
</table>
</html:form>
